#include "alwindow.h"
#include <QPushButton>
#include <QMenuBar>
#include <QLineEdit>
#include <QDebug>
#include <QLabel>
#include <qfont.h>
alwindow::alwindow(QWidget *parent) : QWidget(parent)
{
    QFont font1;
    font1.setPointSize(15);
    this->resize(800,300);
    QLabel * label1 = new QLabel("宽度：",this);
    label1->move(50,100);
    label1->setFont(font1);
    label1->show();
    QLabel * label2 = new QLabel("高度：",this);
    label2->move(250,100);
    label2->setFont(font1);
    label2->show();
    QLabel * label3 = new QLabel("地雷数量：",this);
    label3->move(450,100);
    label3->setFont(font1);
    label3->show();
    QLineEdit * text1 = new QLineEdit(this);
    text1->move(50,150);
    text1->resize(150,40);
    text1->show();
    QLineEdit * text2 = new QLineEdit(this);
    text2->move(250,150);
    text2->resize(150,40);
    text2->show();
    QLineEdit * text3 = new QLineEdit(this);
    text3->move(450,150);
    text3->resize(150,40);
    text3->show();

    QPushButton * sure = new QPushButton("确认",this);
    sure->resize(150,60);
    sure->move(600,230);
    connect(sure,&QPushButton::clicked,this,[=](){
        length = text1 -> text().toInt();
        if(length>40) length = 40;
        if(length<1) length = 1;
        width = text2 -> text().toInt();
        if(width>30) width = 30;
        if(width<1) width = 1;
        num = text3 -> text().toInt();
        if(num>1200) num = 1200;
        if(num<1) num = 1;
        if(num >= length*width) num = length * width - 1;
        emit this->finished();
    });
}
game * alwindow::getpoint(){
    return gamescene;
};
